# !/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
@作者 杨阳
@时间 2018-08-01
@说明 处理生成代码相关的请求
@注意事项
"""

from flask import Blueprint, request
from flask_login import current_user

from model.SystemModel import GenerationModel

code = Blueprint('code', __name__, url_prefix='/code')


@code.route("/grid/", methods=["POST"])
def code_grid():
    """
    查询角色表格
    :return: json 字符串
    """
    current_page = request.form.get("current_page")
    search_name = request.form.get("search_name")

    return GenerationModel.get_database_table_grid(current_page, search_name)


@code.route("/columns/grid/", methods=["POST"])
def code_columns_grid():
    """
    查询某个表的所有字段
    :return:
    """
    table_name = request.form.get("table_name")
    return GenerationModel.get_columns_grid(table_name)
